<?php

namespace App\Api\Logic;

use App\Api\Logic\Validate\UserBankValidate;
use App\Exceptions\ValidationException;
use App\Helpers\ResponseEnum;

class UserBankLogic extends BaseLogic
{
    /**
     * 获取验证的实力对象
     * @return UserBankValidate
     */
    private function getValidate():UserBankValidate{
        return  new UserBankValidate();
    }

    /**
     * @return void
     */
    public function addBank($data){
        $validate = $this->getValidate();
        if(!$validate->scene('addBank')->check($data)){
            throw new ValidationException(ResponseEnum::HTTP_ERROR,$validate->getError());
        }
    }

    /**
     * @param array $data
     * @return void
     * @throws ValidationException
     */
    public function bankInfo(array $data)
    {
        $validate = $this->getValidate();
        if(!$validate->scene('bankInfo')->check($data)){
            throw new ValidationException(ResponseEnum::HTTP_ERROR,$validate->getError());
        }
    }

    /**
     * @param array $data
     * @return void
     */
    public function delBank(array $data)
    {
        $validate = $this->getValidate();
        if(!$validate->scene('delBank')->check($data)){
            throw new ValidationException(ResponseEnum::HTTP_ERROR,$validate->getError());
        }
    }

    /**
     * @param array $data
     * @return void
     * @throws ValidationException
     */
    public function editBank(array $data)
    {
        $validate = $this->getValidate();
        if(!$validate->scene('editBank')->check($data)){
            throw new ValidationException(ResponseEnum::HTTP_ERROR,$validate->getError());
        }
    }
}
